package com.itheima.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.pojo.OrderSetting;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

public interface OrdersettingMapper extends BaseMapper<OrderSetting> {
    @Select("select day(orderdate) date,number,reservations from t_ordersetting where ORDERDATE between #{start} and #{end}")
    public List<Map> findOrderSettingsData(@Param("start") String start,@Param("end") String end);

    @Select("select COUNT(*) from t_ordersetting where ORDERDATE = #{orderDate} and NUMBER > RESERVATIONS")
    int isOrderSettingAvailable(String orderDate);

    @Update("update t_ordersetting set RESERVATIONS = RESERVATIONS + 1 where ORDERDATE = #{orderDate}")
    void addReservationsByOrderDate(String orderDate);
}
